# -*- coding: UTF-8 -*-
from django.forms import ModelForm
from .models import Mongodb,Mysql
from django import forms
from cmdb.models import Server
from myauth.models import  PlatForm
from .models import STATUS_CHOICE
#定义Node的Form,Form名字为 模式名+Form
class MongodbForm(ModelForm):
    #自定义ModelForm的内容
    class Meta:
        #该ModelForm参照Model: Node
        model = Mongodb
        #在Form中不显示node_signer这个字段
        # exclude = ['node_signer']
        #fields=['id','ip','ip_extra']
        exclude=[]


class MysqlForm(ModelForm):
    #自定义ModelForm的内容
    class Meta:
        #该ModelForm参照Model: Node
        model = Mysql
        #在Form中不显示node_signer这个字段
        # exclude = ['node_signer']
        #fields=['id','ip','ip_extra']
        exclude=[]


class Mysql_Search_Form(forms.Form):
    MASTER = 'master'
    SLAVE = 'standby'
    ARCHITECTURE_CHOICES = (
        (MASTER, '主数据库'),
        (SLAVE, '从数据库')
    )
    server = forms.ModelChoiceField(label='服务器:', queryset=Server.objects.all(), to_field_name='id', required=False)
    platform = forms.ModelChoiceField(
        label='平台:', queryset=PlatForm.objects.all(), to_field_name='id', required=False)
    status = forms.ChoiceField(label='安装状态', choices=STATUS_CHOICE, required=False)
    mysql_type= forms.ChoiceField(label='数据库状态', choices=ARCHITECTURE_CHOICES, required=False)
